#!/bin/sh

mx_mapper_state_dir="/var/run/mx_mapper"
fma_run="/var/run/fms"

prefix=@mx_prefix@  #Note this is replaced by make install, not configure!
output=/dev/null

# Uncomment the following line to get the output of this script logged
# to a file for debugging

#output=${mx_mapper_state_dir}/mx_stop_log.$$

for pid_file in `ls "${mx_mapper_state_dir}"/pid.* 2>/dev/null`
do
    # Read the stored PID.
    pid=`cat "${pid_file}"` || return $?
    # Kill the mapper.
    kill "${pid}" 2>/dev/null
    rm -f "${pid_file}"
done

# stop any FMAs
for pid_file in ${fma_run}/fma[_.]pid ; do
 if [ -r ${pid_file} ]
 then
    # Read the stored PID.
    pid=`cat "${pid_file}"` || return $?

    # Kill the FMA
    kill "${pid}" 2>/dev/null
    rm -f "${pid_file}"
 fi
done

sleep 1


